﻿using UnityEngine;
using BehaviorDesigner.Runtime.Tasks;
using BehaviorDesigner.Runtime;

public class MoveToward : Action {

	public float speed;
	public SharedTransform target;
	public SquareMove moveHelper;

	// Use this for initialization
	void Start () {
		moveHelper = transform.GetComponent<SquareMove> ();
	}
	
	// Update is called once per frame
	void Update () {

	}

	public override TaskStatus OnUpdate() {
		if (target.Value==null)
		{
			return TaskStatus.Success;
		}
		else
		{
			if (moveHelper.SetDestination (target.Value.position))
				return TaskStatus.Running;
			else
				return TaskStatus.Success;
		}
	}
}
